package x.java.tea;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class ListInjector extends ObjectInjector implements List<Object> {
	private List<Object> list;

	public ListInjector() {
		this.list = new ArrayList<Object>();
	}

	public ListInjector(Collection<? extends Object> c) {
		this.list = new ArrayList<Object>();
		this.list.addAll(c);
	}

	public ListInjector(Object[] a) {
		this.list = Arrays.asList(a);
	}

	public void setList(Collection<? extends Object> c) {
		this.list = new ArrayList<Object>();
		this.list.addAll(c);
	}

	public void setList(Object[] a) {
		this.list = Arrays.asList(a);
	}
	
	public void add(int index, Object element) {
		list.add(index, element);
	}

	public boolean add(Object e) {
		return list.add(e);
	}

	public boolean addAll(Collection<? extends Object> c) {
		return list.addAll(c);
	}

	public boolean addAll(int index, Collection<? extends Object> c) {
		return list.addAll(index, c);
	}

	public void clear() {
		list.clear();
	}

	public boolean contains(Object o) {
		return list.contains(o);
	}

	public boolean containsAll(Collection<?> c) {
		return list.containsAll(c);
	}

	public boolean equals(Object o) {
		return list.equals(o);
	}

	public Object get(int index) {
		return list.get(index);
	}

	public int hashCode() {
		return list.hashCode();
	}

	public int indexOf(Object o) {
		return list.indexOf(o);
	}

	public boolean isEmpty() {
		return list.isEmpty();
	}

	public Iterator<Object> iterator() {
		return list.iterator();
	}

	public int lastIndexOf(Object o) {
		return list.lastIndexOf(o);
	}

	public ListIterator<Object> listIterator() {
		return list.listIterator();
	}

	public ListIterator<Object> listIterator(int index) {
		return list.listIterator(index);
	}

	public Object remove(int index) {
		return list.remove(index);
	}

	public boolean remove(Object o) {
		return list.remove(o);
	}

	public boolean removeAll(Collection<?> c) {
		return list.removeAll(c);
	}

	public boolean retainAll(Collection<?> c) {
		return list.retainAll(c);
	}

	public Object set(int index, Object element) {
		return list.set(index, element);
	}

	public int size() {
		return list.size();
	}

	public List<Object> subList(int fromIndex, int toIndex) {
		return list.subList(fromIndex, toIndex);
	}

	public Object[] toArray() {
		return list.toArray();
	}

	public <T> T[] toArray(T[] a) {
		return list.toArray(a);
	}

	@Override
	public void init(String id) {
		int idx = Integer.parseInt(id);
		this.obj = list.get(idx);
		super.init(id);
	}
}
